<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

/**
 * App\Models\Project
 *
 * @property int $id
 * @property int $user_id 创建人
 * @property string $title 项目名称
 * @property \Illuminate\Support\Carbon|null $created_at
 * @property \Illuminate\Support\Carbon|null $updated_at
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Project newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Project newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Project query()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Project whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Project whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Project whereTitle($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Project whereUpdatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Project whereUserId($value)
 * @mixin \Eloquent
 * @property int $template 是否是模板
 * @property int $system 是否是系统内置
 * @property int $status 状态
 * @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\CellProp[] $cellProps
 * @property-read int|null $cell_props_count
 * @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Cell[] $cells
 * @property-read int|null $cells_count
 * @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ColumnMeta[] $columnMetas
 * @property-read int|null $column_metas_count
 * @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Column[] $columns
 * @property-read int|null $columns_count
 * @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ProjectComment[] $comments
 * @property-read int|null $comments_count
 * @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Row[] $rows
 * @property-read int|null $rows_count
 * @property-read \App\Models\User $user
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Project whereStatus($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Project whereSystem($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Project whereTemplate($value)
 */
class Project extends Model
{
    protected $fillable = [
        'user_id', 'title', 'template', 'system', 'status'
    ];

    public function columns()
    {
        return $this->hasMany(Column::class);
    }

    public function columnMetas()
    {
        return $this->hasMany(ColumnMeta::class);
    }

    public function rows()
    {
        return $this->hasMany(Row::class);
    }

    public function cells()
    {
        return $this->hasMany(Cell::class);
    }

    public function cellProps() {
        return $this->hasMany(CellProp::class);
    }

    public function comments() {
        return $this->hasMany(ProjectComment::class);
    }

    public function user()
    {
        return $this->belongsTo(User::class);
    }
}
